﻿using System;
using System.Collections.Generic;
using System.Linq;
using OS.Infrastructure.Domain;
using OS.Infrastructure.Domain.UnitOfWork;
using OS.Infrastructure.NHibernate;
using OS.Infrastructure.NHibernate.Repositories;
using TaskKernel.Domain.Interface;

namespace TaskKernel.Domain.Nhibernate.NHibernateLayer
{
    public class QueryProposalForm : BaseRepository<Template>, IQueryProposalForm
    {
        public QueryProposalForm(ISessionProvider sessionProvider, ILinqProvider linqProvider)
            : base(sessionProvider, linqProvider)
        {
        }

        #region IQueryProposalForm Members

        public virtual IEnumerable<Template> GetTemplatesByDepartment(Department department)
        {
            return FilterBy(x => x.Departments.Any(p => p.UID == department.UID));
        }

        public virtual Template GetProposalForm(Guid id)
        {
            return FindBy(x => x.UID == id);
        }

        #endregion
    }
}